class Encrypter
{
public:
    Encrypter(vector<char> &keys, vector<string> &values, vector<string> &dictionary)
    {
        for (int i = 0; i < keys.size(); ++i)
        {
            encryptMap[keys[i]] = values[i];
        }
        for (auto &s : dictionary)
        {
            string encryptedS = encrypt(s);
            ++encryptedDictionary[encryptedS];
        }
    }

    string encrypt(string word1)
    {
        stringstream result;
        for (char c : word1)
        {
            if (encryptMap.count(c))
            {
                result << encryptMap[c];
            }
            else
            {
                return "";
            }
        }
        return result.str();
    }

    int decrypt(string word2)
    {
        if (!encryptedDictionary.count(word2))
        {
            return 0;
        }
        return encryptedDictionary[word2];
    }

private:
    unordered_map<char, string> encryptMap;
    unordered_map<string, int> encryptedDictionary;
};

/**
 * Your Encrypter object will be instantiated and called as such:
 * Encrypter* obj = new Encrypter(keys, values, dictionary);
 * string param_1 = obj->encrypt(word1);
 * int param_2 = obj->decrypt(word2);
 */